package com.kb.erp.controller;

import com.kb.erp.service.SynData;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 一站式编码同步
 * @author cxhello
 * @create 2021/2/6
 */
@Component
public class SyDataXxlJobController {

    private static Logger logger = LoggerFactory.getLogger(SyDataXxlJobController.class);

    @Value("${server.port}")
    private int port;
    @Autowired
    private SynData synData;

    /**
     * 测试用例
     */
    @XxlJob("testXxlJob")
    public void testXxlJob() {
        logger.info("XXL-JOB, Hello World, port: {}.", port);
        XxlJobHelper.log("=========================" );
        XxlJobHelper.log("任务开始" );
        XxlJobHelper.log("--------------------------" );

    }
    /**
     * 测试异常用例
     */
    @XxlJob("testErrXxlJob")
    public void testErrXxlJob() {
        logger.info("XXL-JOB, Hello World, port: {}.", port);
        String a = null;
        String string = a.toString();

    }

    /**
     *  一站式编码数据同步
     */
    @XxlJob("oneStopXxlJob")
    public void oneStopXxlJob() {
        synData.everyDaySynProcessCenter();
    }
}
